﻿using System;
using ePipe;
using System.Runtime.CompilerServices;

namespace Letter.Net.Sockets;

abstract class ASocketSnderProvider<TSnder> : IDisposable where TSnder : ASocketSnder
{
    public ASocketSnderProvider(PipeScheduler scheduler)
    {
        _scheduler = scheduler;
    }

    private readonly PipeScheduler _scheduler;

    public PipeScheduler Scheduler => _scheduler;

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public abstract TSnder Rent();

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public abstract void Return(TSnder sender);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    protected abstract TSnder Create(PipeScheduler scheduler);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public virtual void Dispose()
    {
    }
}

